#include <iostream>
#include <climits>
// zdl:: 这道题只涉及查询，不涉及修改，查找区间内的最小值，所以还是很简单的
using namespace std;
#define lc p << 1
#define rc p << 1 | 1

const int N = 1e5 + 10;
struct node
{
    int l, r, m;
}tr[N << 2];

int n, m;
int a[N];
void pushUp(int p)
{
    tr[p].m = min(tr[lc].m, tr[rc].m);
}

void bulid (int p, int l, int r)
{
    tr[p] = {l, r, a[l]};
    if (r == l) return ;
    int mid{(l + r) >> 1};
    bulid(lc, l, mid), bulid(rc, mid + 1, r);
    pushUp(p);
}
int query(int p, int a, int b)
{
    int l = tr[p].l, r = tr[p].r;
    if (a <= l && r <= b) return tr[p].m;

    int mid{(l + r) >> 1};
    int ret = 1e9 - 1;
    if (mid >= a) ret = min(ret, query(lc, a, b));
    if (mid < b) ret = min(ret, query(rc, a, b));

    return ret;
}

int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i];
    bulid(1, 1, n);
    while (m--)
    {
        int a, b; cin >> a >> b;
        cout << query(1, a, b) << " ";
    }
    return 0;
}